import {message, Button, DatePicker} from 'antd'
import React, {useState, useRef, useEffect} from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'
import { connect, Link } from 'umi'
import {salaryAdjustmentTypeList, securityOperationType} from '@/utils/constant'
import { getSalaryChangePage } from '../service'
import moment from 'moment';

const TableList = () => {
  const actionRef = useRef();

  const columns = [
    {
      title: '工号',
      dataIndex: 'code',
      key:'code',
      hideInSearch: true,
    },
    {
      title: '姓名',
      dataIndex: 'name',
      render: (item, record) => (
        <Link to={`/info/details/${record.oid}`}>{item}</Link>
      ),
    },
    {
      title: '公司名称',
      dataIndex: 'orgname',
      hideInSearch: true,
    },
    {
      title: '部门名称',
      dataIndex: 'unitname',
      hideInSearch: true,
    },
    {
      title: '岗位名称',
      dataIndex: 'jobname',
      hideInSearch: true,
    },
    {
      title: '变动类型',
      dataIndex: 'type',
      hideInSearch: true,
      valueEnum: {
        0: { text: salaryAdjustmentTypeList[0].label},
        1: { text: salaryAdjustmentTypeList[1].label},
        2: { text: salaryAdjustmentTypeList[2].label},
        3: { text: salaryAdjustmentTypeList[3].label},
        4: { text: salaryAdjustmentTypeList[4].label},
        5: { text: salaryAdjustmentTypeList[5].label},
        6: { text: salaryAdjustmentTypeList[6].label},
        7: { text: salaryAdjustmentTypeList[7].label},
      },
    },
    {
      title: '原薪资组',
      dataIndex: 'oidPayrollUnitId',
      hideInSearch: true,
      render:(text,record) => {
        return record.oidSalaryGroupDto && record.oidSalaryGroupDto.cname
      }
    },
    {
      title: '原发薪单位',
      dataIndex: 'beforePayrollUnit',
      key:'beforePayrollUnit',
      hideInSearch: true,
      render: (text,record) => {
        return record.oidSalaryUnitDto && record.oidSalaryUnitDto.cname
      },
    },
    {
      title: '变更后薪资组',
      dataIndex: 'salaryGroupId',
      key:'salaryGroupId',
      hideInSearch: true,
      render:(text,record) => {
        return record.salaryGroupDto && record.salaryGroupDto.cname
      }
    },
    {
      title: '变更后发薪单位',
      dataIndex: 'payrollUnit',
      key:'payrollUnit',
      hideInSearch: true,
      render: (text,record) => {
        return record.salaryUnitDto && record.salaryUnitDto.cname
      },
    },
    {
      title: '分配日期',
      dataIndex: 'distributionTime',
      renderFormItem: (item, props) => {
        return <DatePicker {...props} picker="month" />;
      },
      render: (text,record) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
    {
      title: '操作人',
      dataIndex: 'distributionName',
      hideInSearch: true,
    },
    {
      title: '操作时间',
      dataIndex: 'distributionTime',
      hideInSearch: true,
      renderFormItem: (item, props) => {
        return <DatePicker {...props} picker="month" />;
      },
      render: (text)=>{
        return text!=='-'?moment(text).format('YYYY-MM-DD hh:mm:ss'):''
      }
    },
  ];

  return (
    <PageHeaderWrapper>

      <ProTable
        actionRef={actionRef}
        rowKey="id"
        request={(params) => getSalaryChangePage(params)}
        columns={columns}
      />

    </PageHeaderWrapper>
  )
};

export default connect(({  }) => ({
}))(TableList)
